package bebGraphical;


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Label;

public class Slot extends Label  {
    static int SLOT_W=40;
    static int SLOT_H=70;
    static int slotCount=0;
    static int selectedSlot=-1;
    
    String usedBy=null;
    
    int slotNumber;
    static boolean onClicRestore=false;

    
    /*
 * en haut les attributs 
 * en bas les méthodes 
 */
	private static final long serialVersionUID = 1L;
	
	
	public Slot() {
		slotNumber=slotCount;
		slotCount++;
		this.setPreferredSize(new Dimension(SLOT_W, SLOT_H));
		
	}

	public static void setSelectedSlot(int selectedSlot) {
		Slot.selectedSlot = selectedSlot;
	}
	
	public static int getSelectedSlot() {
		return selectedSlot;
	}

	public static void incrementSelectedSlot(){
		selectedSlot++;
		if(selectedSlot>=slotCount){
			selectedSlot=0;
		}
		
	}
	
	public static void decrementSelectedSlot() {
		selectedSlot--;
		if(selectedSlot<=-1){
			selectedSlot=slotCount-1;
		}
		
	}
	
	public static boolean isOnClicRestore() {
		return onClicRestore;
	}

	public static void setOnClicRestore(boolean onClicRestore) {
		Slot.onClicRestore = onClicRestore;
	}

	public String getUsedBy() {
		return usedBy;
	}

	public void setUsedBy(String usedBy) {
		this.usedBy = usedBy;
	}
	
	public static void resetParam() {
		Slot.slotCount=0;
	}

	public int getSlotNumber() {
		return slotNumber;
	}
	
	public static int getSlotCount() {
		return slotCount;
	}
	
	@Override
	public void paint(Graphics g) {
		if(slotNumber==selectedSlot){
			this.setBackground(Color.yellow);
		}else{
			this.setBackground(Color.white);	
		}
		
		g.setColor(Color.black);
		g.drawString(""+slotNumber, 0, 4*SLOT_H/5);
		g.setFont(new Font("sansserif", Font.BOLD, 20));
		g.drawRect(0, SLOT_H/3, SLOT_W-1, (SLOT_H/(SLOT_H/10))*2);
			
		g.drawString(usedBy, SLOT_W/4, SLOT_H/3+(SLOT_H/(SLOT_H/10))*7/4);	
	}

}



